package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.UserPhysiologySet;
import com.ruoyi.ring.service.IUserPhysiologySetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 生理周期设置Controller
 * 
 * @author liuwp
 * @date 2025-09-30
 */
@RestController
@RequestMapping("/ring/user_physiology_set")
public class UserPhysiologySetController extends BaseController
{
    @Autowired
    private IUserPhysiologySetService userPhysiologySetService;

    /**
     * 查询生理周期设置列表
     */
    @PreAuthorize("@ss.hasPermi('ring:user_physiology_set:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserPhysiologySet userPhysiologySet)
    {
        startPage();
        List<UserPhysiologySet> list = userPhysiologySetService.selectUserPhysiologySetList(userPhysiologySet);
        return getDataTable(list);
    }

    /**
     * 导出生理周期设置列表
     */
    @PreAuthorize("@ss.hasPermi('ring:user_physiology_set:export')")
    @Log(title = "生理周期设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserPhysiologySet userPhysiologySet)
    {
        List<UserPhysiologySet> list = userPhysiologySetService.selectUserPhysiologySetList(userPhysiologySet);
        ExcelUtil<UserPhysiologySet> util = new ExcelUtil<UserPhysiologySet>(UserPhysiologySet.class);
        util.exportExcel(response, list, "生理周期设置数据");
    }

    /**
     * 获取生理周期设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:user_physiology_set:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(userPhysiologySetService.selectUserPhysiologySetById(id));
    }

    /**
     * 新增生理周期设置
     */
    @PreAuthorize("@ss.hasPermi('ring:user_physiology_set:add')")
    @Log(title = "生理周期设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserPhysiologySet userPhysiologySet)
    {
        return toAjax(userPhysiologySetService.insertUserPhysiologySet(userPhysiologySet));
    }

    /**
     * 修改生理周期设置
     */
    @PreAuthorize("@ss.hasPermi('ring:user_physiology_set:edit')")
    @Log(title = "生理周期设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserPhysiologySet userPhysiologySet)
    {
        return toAjax(userPhysiologySetService.updateUserPhysiologySet(userPhysiologySet));
    }

    /**
     * 删除生理周期设置
     */
    @PreAuthorize("@ss.hasPermi('ring:user_physiology_set:remove')")
    @Log(title = "生理周期设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userPhysiologySetService.deleteUserPhysiologySetByIds(ids));
    }
}
